﻿using MySpiderMgr.Domain.Menus.Dtos;
using MySpiderMgr.Infrastructure.BaseEntities;
using MySpiderMgr.Infrastructure.CommonEnums;
using System;
using System.Collections.Generic;
using System.Text;

namespace MySpiderMgr.Domain.Menus
{
    public class MenuItem : OperatorAndDate<string>
    {
        /// <summary>
        /// 编号
        /// </summary>
        public string No { get; set; }
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 地址
        /// </summary>
        public string Url { get; set; }
        /// <summary>
        /// 父级
        /// </summary>
        public string ParentNo { get; set; }
        /// <summary>
        /// 显示顺序
        /// </summary>
        public int OrderBy { get; set; }

        private MenuItem() { }
        /// <summary>
        /// 创建对象
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public static MenuItem Create(CreateMenuItemDto dto)
        {
            return new MenuItem
            {
                CreatedBy = dto.CreatedBy,
                CreatedName = dto.CreatedName,
                CreatedOn = DateTimeOffset.Now,
                Flag = EntityFlag.Normal,
                No = dto.No,
                OrderBy = dto.OrderBy,
                ParentNo = dto.ParentNo,
                Title = dto.Title,
                Url = dto.Url
            };
        }
    }
}
